﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SourceControlEssentials
{
    class Gachevskyi : IStudent
    {
        public override int GetHashCode()
        {
            return 4;
        }

        public int Id()
        {
            return GetHashCode();
        }

        public string GetLastName()
        {
            return "Gachevskyi";
        }

        public string GetFirstName()
        {
            return "Artyom";
        }

        public int GetGroup()
        {
            return 318;
        }

        public string MethodName()
        {
            return "Char numbers";
        }

        public string ExecuteStrategy(string value)
        {
            string result = "";
            SortedDictionary<char, int> countOfChar = new SortedDictionary<char, int>();

            foreach (char ch in value)
            {
                if (countOfChar.ContainsKey(ch))
                    countOfChar[ch]++;
                else
                    countOfChar.Add(ch, 1);
            }

            foreach (char ch in countOfChar.Keys)
            {
                if (ch != ' ')
                    result = result + "\n"+ "Letter " + ch + " occures " + countOfChar[ch].ToString() + " times.";
            }

            return result;
        }
    }
}
